package com.atguigu.controller;

import com.atguigu.comMonutils.R;
import com.atguigu.util.QiniuCloudUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("qiNiuYun")
@CrossOrigin
public class QinniYUnController {

    //上传图片
    @PostMapping("/uploadImage")
    public R test1(@RequestParam("file") MultipartFile file) throws Exception {
        return R.ok().data("url",QiniuCloudUtil.QiniuCloudUploadImage(file));
    }

    //获取图片链接
    @PostMapping("/getImageName")
    public R test2(@RequestParam("fileName") String fileName){
        return R.ok().data("url",QiniuCloudUtil.QiniuCloudDownloadImage(fileName));
    }

//    删除图片
    @PostMapping("/deleteImage")
    public R test3(@RequestBody String[] fileNameList){
        return R.ok().data("url",QiniuCloudUtil.QiniuCloudDeleteImage(fileNameList));
    }

}